"Linka as páginas estáticas criadas na página inicial"

from os import chdir, listdir
from json import load as JsonLoad

TAG = """
<a href="/pages/{folder}" class="container">
  <img src="{image}" />
  <div>
    <h2>{title}</h2>
    <p>{description}</p>
  </div>
</a>
"""

template = open('index.t.md', 'r').read()
output = open('index.md', 'w')
chdir('../pages')

output.write(template)
output.write('<div id="posts">')
posts = []
for folder in listdir():
    info = JsonLoad(open(folder + '/info.json', 'r'))
    posts.append((info['id'], info, folder))

posts.sort(reverse=True)

for _, post, folder in posts:
  output.write(TAG.format(folder=folder, **post))

output.write('</div>')
output.flush()
output.close()